import subprocess


shell = """
net_card=${IF:-$(ip route show default|awk '/default/ {print $5}'|head -1)};
cat /sys/class/net/${net_card}/address
"""


net_card_cmd = """echo ${IF:-$(ip route show default|awk '/default/ {print $5}'|head -1)}"""
mac_cmd = """cat /sys/class/net/{}/address"""

net_card = subprocess.run(['sh', '-c', net_card_cmd], capture_output=True, text=True).stdout.strip()

mac = subprocess.run(['sh', '-c', mac_cmd.format(net_card)], capture_output=True, text=True).stdout.strip()

mac2 = subprocess.run(['sh', '-c', shell], capture_output=True, text=True).stdout.strip()

print(net_card, mac, mac2)
